﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TextManager.Interop;

namespace LuaLanguage
{
    public class BraceMatch
    {
        public BraceMatch(TextSpan start, TextSpan end, int priority)
        {
            this.Start = start;
            this.End = end;
            this.Priority = priority;
        }

        public TextSpan Start
        {
            get; set;
        }

        public TextSpan End
        {
            get; set;
        }

        public int Priority
        {
            get;
            set;
        }

        /// <summary>
        /// Determines if nestedMatch is a nested Brace Match
        /// </summary>
        /// <param name="nestedMatch"></param>
        /// <returns></returns>
        public bool IsNestedMatch(BraceMatch nestedMatch)
        {
            if (nestedMatch.Start.iStartLine > Start.iStartLine ||
                    (nestedMatch.Start.iStartLine == Start.iStartLine &&
                     nestedMatch.Start.iStartIndex > Start.iStartIndex))
            {
                if(nestedMatch.End.iEndLine < End.iEndLine ||
                    (nestedMatch.End.iEndLine == End.iEndLine &&
                    nestedMatch.End.iEndIndex < End.iEndIndex))
                {
                    return true;
                }

            }

            return false;
        }
    }
}
